package net.sipvip.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.PopupPanel;

public class RightImage extends Composite {
	public RightImage(String phone, String name, String imagestr, String city) {
		final String vimagestr = imagestr;
		final String vphone = phone;
		final String vname = name;
		final String vcity = city;
		content = new DecoratorPanel();
		initWidget(content);
		grid = new Grid(4, 1);
		Image image = new Image(imagestr);
		image.setHeight("200px");
		image.setWidth("150px");


		image.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				Utils.track(vphone + " " +vname);
				final PopupPanel imagePopup = new PopupPanel(true);
				imagePopup.setAnimationEnabled(true);
				imagePopup.setWidget(new RightImageBig(vphone, "Soita Nyt!!! " + vname,
						vimagestr, vcity));
				imagePopup.center();
				imagePopup.show();

			}
		});

		grid.setText(0, 0, phone);
		// TODO style
		grid.getCellFormatter().setStyleName(0, 0, "phone");
		grid.setText(1, 0, name);
		// TODO style
		grid.getCellFormatter().setStyleName(1, 0, "name");
		grid.setWidget(2, 0, image);
		// TODO style
		grid.getCellFormatter().setStyleName(2, 0, "image");
		grid.setText(3, 0, city);
		// TODO style
		grid.getCellFormatter().setStyleName(3, 0, "city");

		content.add(grid);

	}

	private DecoratorPanel content;
	private Grid grid;
}
